package com.hmall.common.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;

/**
 * Feign远程调用携带请求头
 */
@Slf4j
@Configuration
public class MyFeignInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        // Feign请求携带Head -> authorization: 2;  FeignClient接口指定configuration属性为MyFeignInterceptor.class即可生效;
        template.header("authorization", "2");
    }
}